package com.unitd.frame.springweb.plugins.velocity.directive;

import org.apache.velocity.context.InternalContextAdapter;
import org.apache.velocity.exception.MethodInvocationException;
import org.apache.velocity.exception.ParseErrorException;
import org.apache.velocity.exception.ResourceNotFoundException;
import org.apache.velocity.runtime.directive.Directive;
import org.apache.velocity.runtime.parser.node.Node;
import org.apache.velocity.tools.view.ViewToolContext;

import java.io.IOException;
import java.io.Writer;


/**
 * @desc 自定义的velocity管理抽象类,它继承自velocity自身的Directive; 用于提供公共的方法对velocity进行管理
 * @filename AbstractDirective.java
 * @copyright www.unitd.com
 * @author Hudan
 * @version 1.0
 * @date 2017/4/1
 */

public abstract class AbstractDirective extends Directive {
	public AbstractDirective() {
	}

	@Override
	public boolean render(InternalContextAdapter internalContext, Writer writer, Node node) throws IOException, ResourceNotFoundException, ParseErrorException, MethodInvocationException {
		ViewToolContext context = (ViewToolContext) internalContext.getInternalUserContext();
		return this.doRender(internalContext, context, writer, node);
	}

	protected abstract boolean doRender(InternalContextAdapter var1, ViewToolContext var2, Writer var3, Node var4) throws IOException, ResourceNotFoundException, ParseErrorException, MethodInvocationException;
}